﻿using MySchool;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsFormsApp1
{
    public partial class Form3 : Form
    {
        DBHelper db = new DBHelper();
        DataSet set = new DataSet();
        public Form3()
        {
            InitializeComponent();
        }

        private void Form3_Load(object sender, EventArgs e)
        {
            db.OpenConnection();
            string sql = "select a.id,a.count,b.teamName,TemaInfo.teamName,a.competitonTime,a.competitionposition,a.score,a.entryperson from ScheduleInfo a inner join TemaInfo b on (a.hostTeamID = b.id) inner join TemaInfo on awayTeamId = TemaInfo.id";
            SqlDataAdapter adapter = new SqlDataAdapter(sql,db.Connection);
            adapter.Fill(set,"ScheduleInfo");
            this.dataGridView1.DataSource = set.Tables["ScheduleInfo"];
            db.CloseConnection();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            set.Tables["ScheduleInfo"].Clear();
            db.OpenConnection();
            string sql = "select a.id,a.count,b.teamName,TemaInfo.teamName,a.competitonTime,a.competitionposition,a.score,a.entryperson from ScheduleInfo a inner join TemaInfo b on (a.hostTeamID = b.id) inner join TemaInfo on awayTeamId = TemaInfo.id  where b.teamName=N'" + this.textBox1.Text + "'";
            SqlDataAdapter adapter = new SqlDataAdapter(sql, db.Connection);
            adapter.Fill(set, "ScheduleInfo");
            this.dataGridView1.DataSource = set.Tables["ScheduleInfo"];


        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
